-- cure_hp
-- create by shuzy
-- 技能: 恢复百分比生命值


return {
    apply = function(source, target, skillId, round, para, extra)
        local hp = 0;
        
        if para[2] == 1 then
            -- 1. 威力
            local force = para[1];
            -- 2. 施展方的最大生命值
            local maxHp = source:getMaxHp();
            -- 3. 作用
            hp = math.modf(maxHp * force / 1000);
        elseif para[2] == 2 then
            hp = para[1];
        end

        -- 增加命中动作
        SkillM.getSequence(target):hit(source, target, skillId);

        CombatM.receiveCure(source, target, hp);

        EventMgr.fire(event.HP_RECOVER, hp);

        -- 作用目标
        return { target, };
    end,

    check = function(skillId, para)
        local dbase = SkillM.query(skillId, "dbase");
        if type(dbase) == "table" and dbase["clean_debuff"] == 1 then
            -- 是类似于痊愈术的技能
            return true;
        end
        local ret = DungeonM.canRecoverAttrib(ME.user, "hp");
        return ret;
    end,

    parse = function(desc)
        local arr = string.explode(desc, ",");
        local ret = {};

        for i = 1, #arr do
            table.insert(ret, tonumber(arr[i]));
        end
        return ret;
    end,

    -- 解析技能描述
    parseDesc = function(source, skillId, desc, para)
        local force = para[1];
        if para[2] == 1 then
            desc = string.gsub(desc, "{number}", tostring(force / 10).."%%" );
        elseif para[2] == 2 then
            desc = string.gsub(desc, "{number}", force );
        end
        return desc;
    end,
}
